package cloud.alibaba.study.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class DateUtil {

	public static LocalDate getNow() {
		return LocalDate.now();
	}
	
	public static Date getCurDate() {
		return new Date();
	}
	
	public static Long getCurDate2Long() {
		return getCurDate().getTime();
	}
	

	/**
	 * 获取当天的开始时间
	 */
	public static String getStartDateTime() {
		LocalDateTime dateTime = LocalDateTime.of(getNow(), LocalTime.MIN);
		return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
	}

	/**
	 * 获取当天的结束时间
	 */
	public static String getEndDateTime() {
		return getDaysLaterDateTime(0);
	}

	/**
	 * 获取多少天后的结束时间
	 */
	public static String getDaysLaterDateTime(int day) {
		LocalDateTime dateTime = LocalDateTime.of(getNow().plusDays(day), LocalTime.MAX);
		return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
	}

	public static void main(String[] args) {
		System.out.println(DateUtil.getStartDateTime());
		System.out.println(getDaysLaterDateTime(3));
	}

}
